<?php
declare (strict_types=1);

namespace app\http\Middleware;

use app\Request;
use think\facade\Session;
use think\facade\Db;

class ManageMiddleware
{
    /**
     * 处理请求
     */
    public function handle($request, \Closure $next)
    {
        $accountInfo = Session::get('manage_admin');
        if (!$accountInfo) {
            if ($request->isAjax()) {
                return apiResponse(STATUS_CODE_UNLOGIN, '登录已过期，请重新登录');
            } else {
                return redirect('/manage/login');
            }
        }
        $request->account = $accountInfo;
        return $next($request);
    }

}